<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Casts\Attribute;
use DateTimeInterface;

class News extends Model
{
    //
   protected  $table = 'dg_news';

   protected  $fillable=['title','image','content','status'];
   
   const ACTIVE = 1;
   const INVALID = -1;
       /**
     * 为 array / JSON 序列化准备日期格式
     *
     * @param  \DateTimeInterface  $date
     * @return string
     */
    protected function serializeDate(DateTimeInterface $date)
    {
        return $date->format('Y-m-d H:i:s');
    }
    protected  function image():Attribute
    {
        return Attribute::make(
            get:fn($value)=>"https://dg.daguozhensi.com{$value}"
        );
    }
}